package com.ruoyi.aqi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aqi.domain.AirQualityHour;
import com.ruoyi.aqi.service.IAirQualityHourService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 空气质量小时Controller
 * 
 * @author houtaroy
 * @date 2024-03-25
 */
@RestController
@RequestMapping("/aqi/airQualityHour")
public class AirQualityHourController extends BaseController
{
    @Autowired
    private IAirQualityHourService airQualityHourService;

    /**
     * 查询空气质量小时列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:list')")
    @GetMapping("/list")
    public TableDataInfo list(AirQualityHour airQualityHour)
    {
        startPage();
        List<AirQualityHour> list = airQualityHourService.selectAirQualityHourList(airQualityHour);
        return getDataTable(list);
    }

    /**
     * 导出空气质量小时列表
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:export')")
    @Log(title = "空气质量小时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AirQualityHour airQualityHour)
    {
        List<AirQualityHour> list = airQualityHourService.selectAirQualityHourList(airQualityHour);
        ExcelUtil<AirQualityHour> util = new ExcelUtil<AirQualityHour>(AirQualityHour.class);
        util.exportExcel(response, list, "空气质量小时数据");
    }

    /**
     * 获取空气质量小时详细信息
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(airQualityHourService.selectAirQualityHourById(id));
    }

    /**
     * 新增空气质量小时
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:add')")
    @Log(title = "空气质量小时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AirQualityHour airQualityHour)
    {
        return toAjax(airQualityHourService.insertAirQualityHour(airQualityHour));
    }

    /**
     * 修改空气质量小时
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:edit')")
    @Log(title = "空气质量小时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AirQualityHour airQualityHour)
    {
        return toAjax(airQualityHourService.updateAirQualityHour(airQualityHour));
    }

    /**
     * 删除空气质量小时
     */
    @PreAuthorize("@ss.hasPermi('aqi:airQualityHour:remove')")
    @Log(title = "空气质量小时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(airQualityHourService.deleteAirQualityHourByIds(ids));
    }
}
